/**
 * @description 地图MapModular
 * @author zr
 */
function loadScript(url, ids) {
  let isLoaded = false
  return new Promise((resolve, reject) => {
    const sf = document.getElementById(ids)
    if (sf != null) {
      resolve()
      return true
    }
    if (isLoaded) {
      resolve()
      return true
    }
    const script = document.createElement('script')
    script.type = 'text/javascript'
    script.charset = 'utf-8'
    script.async = true
    script.id = ids
    script.src = url
    script.onerror = reject
    script.onload = function() {
      isLoaded = true
      resolve()
    }
    document.head.appendChild(script)
  })
}
export default loadScript
